﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using Com.Ctrip.Framework.Apollo;

/// <summary>
/// Dotnet4.5 DotnetCore
/// </summary>
namespace Ctrip_Apollo_Client2.Controllers
{
    public class ConfigController : ApiController
    {
        const string NOT_FOUND = "NotFound";
        public async Task<Dictionary<string, object>> Get()
        {
            // 如果需要支持.Net Core的Apollo版本，可以参考dotnet-core: https://github.com/ctripcorp/apollo.net/tree/dotnet-core
            // 以及nuget仓库
            // 配置文档说明地址：https://github.com/ctripcorp/apollo.net/blob/dotnet-core/Apollo.ConfigurationManager/README.md

            var dic = new Dictionary<string, object>();

            var config = await ApolloConfigurationManager.GetAppConfig();

            dic.Add("client-2-timeout", config.GetProperty("timeout", NOT_FOUND));
            


            return dic;
        }
    }
}
